import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';

class FreightSmartLoginPage extends StatefulWidget {

  @override
  State<FreightSmartLoginPage> createState() => _FreightSmartLoginPageState();

}

class _FreightSmartLoginPageState extends State<FreightSmartLoginPage> {

  bool _isChecked = false;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Stack(
        children: <Widget>[
          Align(
            alignment: Alignment.topCenter,
            child: Image(image: AssetImage(
              'assets/images/home_banner_overlay_cny.png',
            )),
          ),
          Center(
              child: Container(
                height: 400,
                margin: EdgeInsets.symmetric(horizontal: 32),
                child: Column(
                  children: [
                    TextField(
                      decoration: InputDecoration(
                        labelText: 'Username',
                        border: UnderlineInputBorder(),
                        prefixIcon: Icon(Icons.person),
                        focusedBorder: UnderlineInputBorder( // 当TextField获得焦点时使用的边框
                          borderSide: BorderSide(color: Color(0xffE22E4F)), // 自定义颜色
                        ),
                      ),
                      keyboardType: TextInputType.text,
                      cursorColor: Color(0xffE22E4F)
                    ),
                    SizedBox(height: 16),
                    TextField(
                      decoration: InputDecoration(
                        labelText: 'Password',
                        border: UnderlineInputBorder(),
                        prefixIcon: Icon(Icons.lock),
                        focusedBorder: UnderlineInputBorder( // 当TextField获得焦点时使用的边框
                          borderSide: BorderSide(color: Color(0xffE22E4F)), // 自定义颜色
                        ),
                      ),
                      keyboardType: TextInputType.text,
                      cursorColor: Color(0xffE22E4F),
                      obscureText: true,
                    ),
                    Row(
                      children: <Widget>[
                        Checkbox(
                          value: _isChecked, // 假设有一个名为 _isChecked 的状态变量
                          onChanged: (bool? value) {
                            _isChecked = !_isChecked;
                            setState(() {});
                          },
                          activeColor: Color(0xffE22E4F),
                        ),
                        Expanded(
                          child: RichText(
                            text: TextSpan(
                              style: TextStyle(color: Colors.black, fontSize: 14.0),
                              children: <TextSpan>[
                                TextSpan(text: '我已阅读并同意'),
                                TextSpan(
                                  text: '《用户协议》',
                                  style: TextStyle(color: Colors.blue),
                                  recognizer: TapGestureRecognizer()
                                    ..onTap = () {
                                      // 添加“用户协议”的点击事件处理逻辑
                                    },
                                ),
                                TextSpan(text: '和'),
                                TextSpan(
                                  text: '《隐私政策》',
                                  style: TextStyle(color: Colors.blue),
                                  recognizer: TapGestureRecognizer()
                                    ..onTap = () {
                                      // 添加“隐私政策”的点击事件处理逻辑
                                    },
                                ),
                              ]
                            )
                          )
                        )
                      ],
                    ),
                    Container(
                      width: double.infinity,
                      margin: EdgeInsets.only(top: 16),
                      child: ElevatedButton(
                        style: ButtonStyle(
                          backgroundColor: MaterialStateProperty.all(Color(0xffE22E4F)),
                          shape: MaterialStateProperty.all(RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))),
                        ),
                        onPressed: () {
                          Navigator.of(context).pushNamed('/home');
                        },
                        child: Text('登录', style: TextStyle(color: Colors.white),),
                      ),
                    ),
                    GestureDetector(
                      child: Container(
                        margin: EdgeInsets.only(top: 32),
                        child: Column(
                          children: [
                            SizedBox(
                              width: 36,
                              height: 36,
                              child: Image.asset(
                                'assets/images/icon_wx_logo.png',
                              ),
                            ),
                            Text(
                              '微信登录'
                            )
                          ],
                        ),
                      ),
                    )
                  ],
                ),
              ),
          )
        ],
      ),
    );
  }

}